fn main() {
	// V has only one looping keyword: for, with several forms
	// for/in: most common form with an array, map or numeric range
	
	// array for
	numbers := [1, 2, 3, 4, 5]
	for num in numbers {
		println(num)
	}
	
	names := ['Sam', 'Peter']
	for i, name in names {
		println('$i) $name')
	}
	
	// modify an array while looping
	mut mut_numbers := [0, 1, 2]
	for mut num in mut_numbers {
		num++
	}
	println(mut_numbers) // [1, 2, 3]

	// map for
	m := {
		'one': 1
		'two': 2
	}
	for key, value in m {
		println('$key -> $value')
	}
	
	// either key or value can be ignored
	m_2 := {
		'one': 1
		'two': 2
	}
	// iterate over keys
	for key, _ in m_2 {
		println(key)
	}
	// iterate over values
	for _, value in m_2 {
		println(value)
	}
	
	// range for
	// low..high means an exclusive range, from low up to but not including high
	for i in 0 .. 5 {
		print(i)
	}
	println('')
	
	// condition for
	// no parentheses surrounding the condition
	// the braces are always required
	mut sum := 0
	mut i := 0
	for i <= 100 {
		sum += i
		i++
	}
	println(sum) // "5050"

	// bare for
	mut num := 0
	for {
		num += 2
		if num >= 10 {
			break
		}
	}
	println(num) // "10"

	// C for
	// i doesn't need to be declared with mut
	// it's always going to be mutable by definition
	for j := 0; j < 10; j += 2 {
		// Don't print 6
		if j == 6 {
			continue
		}
		println(j)
	}

	// labelled break & continue
	outer: for k := 4; true; k++ {
		println(k)
		for {
			if k < 7 {
				continue outer
			} else {
				break outer
			}
		}
	}
}
